print("========================")
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
print(bicycles)
print(bicycles[1])
# 访问最后一个元素
print(bicycles[-1])
print("arrays length is " + str(len(bicycles)))
print("========================")

motorcycles = ['honda', 'yamaha', 'suzuki']
print(motorcycles)
motorcycles[0] = 'ducati'
print(motorcycles)
motorcycles.append('ducati')
print(motorcycles)
print("========================")

motorcycles = []
print(motorcycles)
motorcycles.append('honda')
motorcycles.append('yamaha')
print(motorcycles)
print("========================")

motorcycles.insert(2, 'suzuki')
print(motorcycles)
del motorcycles[1]
print(motorcycles)
print("========================")

motorcycles = ['honda', 'yamaha', 'suzuki']
popped_motorcycle = motorcycles.pop()
print(motorcycles)
print(popped_motorcycle)
print("========================")

motorcycles = ['honda', 'yamaha', 'suzuki']
first_owned = motorcycles.pop(0)
print('The first motorcycle I owned was a ' + first_owned.title() + '.')
print("========================")

motorcycles = ['honda', 'yamaha', 'suzuki', 'ducati']
print(motorcycles)
too_expensive = 'ducati'
motorcycles.remove(too_expensive)
print(motorcycles)
print("\nA " + too_expensive.title() + " is too expensive for me.")
print("========================")

cars = ['bmw', 'audi', 'toyota', 'subaru']
print(cars)
cars.sort()
print(cars)
cars.sort(reverse=True)
print(cars)
print("========================")

cars = ['bmw', 'audi', 'toyota', 'subaru']
print("Here is the original list:")
print(cars)
print("\nHere is the sorted list:")
print(sorted(cars))
print("\nHere is the original list again:")
print(cars)
print("========================")

magicians = ['alice', 'david', 'carolina']
for magician in magicians:
    print(magician)
    print(magician.title() + ", that was a great trick!")
    print("I can't wait to see your next trick, " + magician.title() + ".\n")
print("========================")

for value in range(1, 10):
    print(value)
print("========================")

list_numbers = list(range(1, 6))
print(list_numbers)
print("========================")

even_numbers_1 = list(range(1, 11, 2))
even_numbers_2 = list(range(2, 11, 2))
print(even_numbers_1)
print(even_numbers_2)
print("========================")

digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
print(min(digits))
print(max(digits))
print(sum(digits))
print("========================")

squares = [value ** 2 for value in range(1, 10)]
print(squares)
print("========================")

# 列表切片
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])
# 自动从头开始
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[:4])
# 自动到尾部结束
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[2:])
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[-3:])
print("========================")

players = ['charles', 'martina', 'michael', 'florence', 'eli']
print("Here are the first three players on my team:")
for player in players[:3]:
    print(player.title())
print("========================")

my_foods = ['pizza', 'falafel', 'carrot cake']
# 会有两个不同的列表存在
friend_foods = my_foods[:]
my_foods.append('cannoli')
friend_foods.append('ice cream')
print(my_foods)
print(friend_foods)
print("========================")

my_foods = ['pizza', 'falafel', 'carrot cake']
# 这行不通
friend_foods = my_foods
my_foods.append('cannoli')
print(my_foods)
friend_foods.append('ice cream')
print(my_foods)
print(friend_foods)
print("========================")

# 元组中的数据时不可变的
dimensions = (200, 50)
print(dimensions[1])
print("========================")

